<template>
    <el-row :gutter="20">
      <el-col :span="19">
        <div class="mt-6" ref="printSection">
          <el-form :model="dataForm"  ref="dataForm" label-width="130px" size="small">
            <el-form-item label="计量器编号" prop="meterCode">
              <el-input v-model="dataForm.meterCode" disabled>   </el-input>
            </el-form-item>
            <el-form-item label="计量器名称" prop="meterName">
              <el-input v-model="dataForm.meterName" disabled>   </el-input>
            </el-form-item>
            <el-form-item label="计量器安装位置" prop="meterAddress">
              <el-input v-model="dataForm.meterAddress" disabled>   </el-input>
            </el-form-item>
            <el-form-item label="设备状态" prop="status">
              <el-radio v-model="dataForm.status" label="1">正常</el-radio>
              <el-radio v-model="dataForm.status" label="2">缺陷</el-radio>
            </el-form-item>
            <!--<el-form-item label="巡检人" prop="patrolUserId">-->
              <!--<el-select v-model="dataForm.patrolUserId" filterable  placeholder="巡检人">-->
                <!--<el-option-->
                  <!--v-for="item in userList"-->
                  <!--:key="item.userId"-->
                  <!--:label="item.username"-->
                  <!--:value="item.userId">-->
                <!--</el-option>-->
              <!--</el-select>-->
            <!--</el-form-item>-->
            <el-form-item :label="dataForm.status=='1'?'备注':'缺陷描述'">
              <el-input v-model="dataForm.remark" type="textarea" :maxlength="200"
                        :rows="2"></el-input>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="dataFormSubmit()">提交</el-button>
            </el-form-item>
          </el-form>
        </div>

      </el-col>
    </el-row>
</template>

<script>
  import { mapGetters } from 'vuex'
  import areaTree from '../energyAnalysis/compont/area_tree'
  import dayjs from 'dayjs'
  import * as Util from "@/utils";
  export default {
    name: 'meterinfo',
    data() {
      return {
        allCheck: false,
        buildList:[],
        dataList:[],
        meterTypeList:[],
        currentUnit:"",
        dataForm:{
          meterCode:'',
          meterName:'',
          meterAddress:'',
          status:'1',
          remark:''
        }
      }
    },
    computed: {
      ...mapGetters('d2admin/theme', ['activeSetting'])
    },
    components: {
      areaTree
    },
    created() {
      this.dataForm.meterCode = this.$route.query.meterCode;
      this.getMeterCodeInfo()
    },
    methods: {
      dataFormSubmit(){
          this.$api.okhttp({
            url: '/ecs/ecspatrolplanrecord/submitRecord',
            method: 'post',
            data: this.$http.adornParams(
              {
                meterCode:  this.dataForm.meterCode,
                status: this.dataForm.status,
                remark: this.dataForm.remark,
              }
            )
          }).then((data) => {
            if (data && data.code === 0) {
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {
                }
              })
            } else {
              this.$message.error(data.msg)
            }
          })
      },
      getMeterCodeInfo(){
        this.$api.okhttp({
          url: `/ecs/ecsmeterinfo/getInfoByCode/${this.dataForm.meterCode}`,
          method: 'get',
          params: this.$http.adornParams()
        }).then((data) => {
          if (data && data.code === 0) {
            this.dataForm.meterName = data.info.meterName
            this.dataForm.meterAddress = data.info.meterSetupaddr
          } else {
          }
        })
      }
    }
  }
</script>

<style>
  .device-btn-box {
    height: 38px;
    overflow: hidden;
    clear: both;
    margin: 20px;
  }

  .radio-box {
    float: left;
    margin-top: 2px;
  }

</style>
